import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

// import { h } from 'vue';
import { DictEnum } from '@vben/constants';
// import { VbenIcon } from '@vben/icons';
import { getPopupContainer } from '@vben/utils';

// import { Tag } from 'ant-design-vue';
// import { z } from '#/adapter/form';
import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'name',
    label: '任务名称',
  },
  {
    label: '所属展会',
    fieldName: 'exhibitionId',
    component: 'ExhibitionSelect',
  },
  {
    component: 'Select',
    componentProps: {
      getPopupContainer,
      options: getDictOptions(DictEnum.EXHIBITION_NUMBER, true),
    },
    fieldName: 'number',
    label: '届数',
  },
];

export const columns: VxeGridProps['columns'] = [
  { type: 'checkbox', width: 60 },
  {
    title: '任务名称',
    field: 'name',
    minWidth: 320,
  },
  {
    title: '所属展会',
    field: 'exhibitionName',
    width: 200,
  },
  {
    title: '届数',
    field: 'number',
    width: 130,
    slots: {
      default: ({ row }) => {
        return renderDict(row.number, DictEnum.EXHIBITION_NUMBER, true);
      },
    },
  },
  {
    title: '区域',
    field: 'area',
    width: 100,
    slots: {
      default: ({ row }) => {
        return renderDict(row.area, DictEnum.BUS_AREA);
      },
    },
  },
  {
    title: '参观团数量',
    field: 'busNum',
    width: 130,
    slots: { default: 'busNum' },
  },
  {
    title: '备注',
    field: 'remark',
    width: 180,
    showOverflow: true,
  },
  {
    title: '创建人',
    field: 'createByName',
    width: 130,
  },
  {
    title: '创建时间',
    field: 'createTime',
    width: 170,
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 180,
  },
];

export const drawerSchema: FormSchemaGetter = () => [
  {
    label: '巴士任务ID',
    fieldName: 'id',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    label: '任务名称',
    fieldName: 'name',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '所属展会',
    fieldName: 'exhibitionId',
    component: 'ExhibitionSelect',
    rules: 'selectRequired',
  },
  {
    label: '届数',
    fieldName: 'number',
    component: 'Select',
    componentProps: {
      getPopupContainer,
      options: getDictOptions(DictEnum.EXHIBITION_NUMBER, true),
    },
    rules: 'selectRequired',
  },
  {
    label: '区域',
    fieldName: 'area',
    component: 'RadioGroup',
    componentProps: {
      buttonStyle: 'solid',
      options: getDictOptions(DictEnum.BUS_AREA),
      optionType: 'button',
    },
    rules: 'selectRequired',
  },
  {
    label: '备注',
    fieldName: 'remark',
    component: 'Textarea',
    componentProps: {
      autoSize: { minRows: 3 },
    },
  },
];

export const detailsSchema: DetailsModalSchemaGetter = () => [
  {
    label: '任务名称',
    fieldName: 'name',
    copy: true,
  },
  {
    label: '所属展会',
    fieldName: 'exhibitionName',
    copy: true,
  },
  {
    label: '届数',
    fieldName: 'number',
    dictEnum: DictEnum.EXHIBITION_NUMBER,
    dictEnumFormatNumber: true,
  },
  {
    label: '区域',
    fieldName: 'area',
    dictEnum: DictEnum.BUS_AREA,
  },
  {
    label: '参观团数量',
    fieldName: 'busNum',
  },
  {
    label: '备注',
    fieldName: 'remark',
    textWrap: true,
  },
];
